
function validateManageTasks(){
    selectionMade = false;
    error = "";
    
    if (document.mainform.buttonPressed.value == 'SEARCH') {
	
        var orderIDEntered = false;
		var orderID = trim(document.mainform.orderID.value);
        if (orderID != "") 
            orderIDEntered = true;
			
        var employeeIDEntered = false;
		var employeeID = trim(document.mainform.employeeID.value);
        if (employeeID != "") 
            employeeIDEntered = true;
			
        var dateAssignedEntered = false;
		var dateAssigned = trim(document.mainform.dateAssigned.value);
        if (dateAssigned != "") 
            dateAssignedEntered = true;
        
		if (!orderIDEntered && !employeeIDEntered && !dateAssignedEntered) {
			error = "&nbsp;&bull;Please enter a search option.<br/>"
		}
		else {
		
			if ((orderIDEntered && employeeIDEntered) ||
			(orderIDEntered && dateAssignedEntered) ||
			(employeeIDEntered && dateAssignedEntered)) {
			
				error = "&nbsp;&bull;Please enter one search option only.<br/>"
			}
			else {
				if (dateAssignedEntered) {
					var dateRegExp = new RegExp("^20[0-9][0-9]-(0[1-9]|10|11|12)-([012][0-9]|3[01])$");
					if (!dateRegExp.test(dateAssigned)) {
						error = "&nbsp;&bull;Date must be in YYYY-MM-DD format.<br/>";
					}
				}
				if (orderIDEntered) {
					var orderRegExp = new RegExp("^[0-9]{15}$");
					if (!orderRegExp.test(orderID)) {
						error = "&nbsp;&bull;Order ID must be a 15 digit number.<br/>";
					}
				}
				if (employeeIDEntered) {
					var employeeRegExp = new RegExp("^[0-9]+$");
					if (!employeeRegExp.test(employeeID)) {
						error = "&nbsp;&bull;Employee ID should be a number.<br/>";
					}
				}
			}
			
		}
    }
    else if (document.mainform.buttonPressed.value != 'VIEW' && document.mainform.buttonPressed.value != 'PRINT'){
        for (i = 0; i < document.getElementById("taskCount").value; i++) {
        
            if (document.getElementById("selectedTask" + i).checked) {
                selectionMade = true;
            }
        }
        if (!selectionMade) {
            error = "&nbsp;&bull;Please select task.<br/>"
        }
        
      
    }
	  return decideOnSubmit(error);
}
